<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%message}}".
 *
 * @property int $id
 * @property int $hid
 * @property string $title
 * @property string $content
 * @property int $create_at
 */
class MessageModel extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%message}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['hid', 'create_at'], 'required'],
            [['hid', 'create_at'], 'integer'],
            [['title'], 'string', 'max' => 50],
            [['content'], 'string', 'max' => 500],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'hid' => '房源id',
            'title' => '标题',
            'content' => '内容',
            'create_at' => '添加时间',
        ];
    }

    public function getHouse(){
        return $this->hasOne(HouseModel::className(),['id'=>'hid']);
    }
}
